<template>
  <div style="padding: 24px;">
    <div
      style="font-size: 16px;font-weight: 500;color: #1D2129;margin-bottom: 16px;"
    >
      传统项目学校类别数据
    </div>
    <div>
      <div style="display: flex; width: 50%;">
        <div>
          <div style="font-size: 24px;color: #0F0F0F;">34,201</div>
          <div style="font-size: 12px;">体育场地数量</div>
        </div>
      </div>
    </div>
    <div id="Chart3" style="width:100%;height:261px"></div>
  </div>
</template>

<script>
import * as echarts from "echarts";
export default {
  data() {
    return {
      chartInstance: null
    };
  },
  mounted() {
    this.datalist();
  },

  methods: {
    datalist() {
      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById("Chart3"));
      // 指定图表的配置项和数据
      var option;
      option = {
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            crossStyle: {
              color: "#999"
            }
          }
        },
        toolbox: {},
        legend: {
          data: ["Evaporation", "Precipitation", "Temperature"]
        },
        xAxis: [
          {
            type: "category",
            data: [
              "小学",
              "初中",
              "高中",
              "小学、初中一体",
              "初中、高中一体",
              "小初高中一体",
              "Sun"
            ],
            axisPointer: {
              type: "shadow"
            }
          }
        ],
        yAxis: [
          {
            type: "value",
            name: "所",
            min: 0,
            max: 250,
            interval: 50,
            axisLabel: {
              formatter: "{value} "
            }
          },
          {
            type: "value",
            name: "人",
            min: 0,
            max: 25,
            interval: 5,
            axisLabel: {
              formatter: "{value} "
            }
          }
        ],
        series: [
          {
            name: "所",
            type: "bar",
            tooltip: {
              valueFormatter: function(value) {
                return value;
              }
            },
            data: [
              2.6,
              5.9,
              9.0,
              26.4,
              28.7,
              70.7,
              175.6,
              182.2,
              48.7,
              18.8,
              6.0,
              2.3
            ]
          },
          {
            name: "人",
            type: "line",
            yAxisIndex: 1,
            tooltip: {
              valueFormatter: function(value) {
                return value;
              }
            },
            data: [
              2.0,
              2.2,
              3.3,
              4.5,
              6.3,
              10.2,
              20.3,
              23.4,
              23.0,
              16.5,
              12.0,
              6.2
            ]
          }
        ]
      };
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
      // 监听父元素大小变化 刷新图表
      var ro = new ResizeObserver(entries => {
        for (let entry of entries) {
          const cr = entry.contentRect;
          myChart.resize();
        }
      });
      ro.observe(Chart);
    }
  }
};
</script>

<style scoped>
.dianidan {
  width: 7px;
  height: 7px;
  margin-right: 5px;
  margin-top: 3px;
}
</style>
